#include <stdio.h>
#include <stdlib.h>
#include "network.h"
#include "common.h"


int main(int argi, char * argv[]) 
{
  if (argi != 2) {
    printf("\tUsage: client [url]\n\n");
  } else {
    int count = 0;
    int socket_id = socket_open(argv[1]);
    ssize_t r = read(socket_id, &count, sizeof(count));
    if (r == 0) {
      printf("Server exited unexpectedly.");
    } else if (r == -1) {
      printf("Error in reading.");
    } else {
      count = ntohl(count);
      printf("I recieved: %d\n", count);
    }
    error_if(close(socket_id) == -1, "Error in closing");
    
  }
  return 0;
}

